import {getUserList} from "@/api/wx";
import {Message} from 'element-ui'

export default {
    namespace:true,
    state:{
        userList:[],
        totalCount:0
    },
    mutations:{
        setUserList(state,list){
            state.userList = list
        },
        setTotalCount(state,count){
            state.totalCount = count
        }
    },
    actions:{
        getUserList({commit},params){
            getUserList(params)
                .then(res => {
                    let data = res.data
                    if (data && data.code === 200) {
                        commit("setUserList",data.page.list)
                        commit("setTotalCount",data.page.totalCount)
                        console.log("数据项列表内容",data.page.list,data.page.totalCount)
                    } else {
                        Message.error(data.msg)
                    }
                })
                .catch(error => {
                    Message.error('用户列表获取异常！')
                    console.warn(error)
                })
        }
    }
}